package com.example.mylibrary.utils;

import android.content.Context;
import android.util.TypedValue;

/**
 * Created by qundui on 2017/4/14.
 */

public class Dputils {
    public static int dp2px(int dp, Context ctx){
        return  (int) TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_DIP,dp,
                ctx.getResources().getDisplayMetrics());
    }
    public static int sp2px(int sp,Context ctx){
        return  (int) TypedValue.applyDimension(
                TypedValue.COMPLEX_UNIT_SP,sp,
                ctx.getResources().getDisplayMetrics());
    }
}
